package com.ianmoone.JZOF;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class BKTest {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
	    in.nextLine();
	    List<int[]> list = new ArrayList<>();
	    List<Integer> wrong = new ArrayList<>();
	    int i = 0;
	    int wrongNum = 0;
	    while(in.hasNextLine()&&i++<n){
	    	int start = in.nextInt();
	    	int end = in.nextInt();
	    	int a[] = new int[2];
	    	a[0] = start;
	    	a[1] = end;
	    	for(int[] b :list){
	    		if (a[0]>=b[0]&&a[0]<b[1]) {
					wrong.add(list.size()+1);
					wrongNum++;
					
				}
	    	}
	    	list.add(a);
	    }
	    if (wrongNum == 0 ) {
			System.out.println(n);
			int j = 1;
			for (int[] a : list){
				if (j!=list.size()) {
					System.out.print(j++ +" ");
				}else {
					System.out.print(j++);
				}
				
			}
		}else{
			if (wrongNum>1) {
				System.out.print("0");
			}else {
				System.out.println(wrongNum);
				for (int a : wrong){
					System.out.print(a);
				}
			}
			
		}
	}
	 
}
